

package com.hexinfo.dmpro.script.config.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hexinfo.dmpro.common.annotation.AnonymousAccess;
import org.springframework.http.ResponseEntity;
import com.hexinfo.dmpro.script.config.model.RolesPublishuser;
import com.hexinfo.dmpro.script.config.service.RolesPublishuserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;


/**
 * role_publishuser表
 *
 * @author zl
 * @date 2024-02-06 10:54:23
 */
@RestController
@AllArgsConstructor
@RequestMapping("/api/rolespublishuser" )
@Api(value = "rolespublishuser", tags = "role_publishuser表管理")
public class RolesPublishuserController {

    private final  RolesPublishuserService rolesPublishuserService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param rolesPublishuser role_publishuser表
     * WrapperEnhancer.like(rolesPublishuser); //自动拼接存在值sql的方法
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page" )
    public ResponseEntity<Object> getRolesPublishuserPage(Page page, RolesPublishuser rolesPublishuser) {
        return ResponseEntity.ok(rolesPublishuserService.queryList(page,rolesPublishuser));
    }


    //不分页通过roleId查
    @GetMapping("/id/{id}")
    @AnonymousAccess
    public ResponseEntity<Object> getRolesPublishuserNoPage(@PathVariable String id){
        return ResponseEntity.ok(rolesPublishuserService.queryListNoPage(id));
    }

    /**
     * 通过id查询role_publishuser表
     * @param roleId id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{roleId}" )
    public ResponseEntity<Object> getById(@PathVariable("roleId" ) String roleId) {
        return ResponseEntity.ok(rolesPublishuserService.getById(roleId));
    }

    /**
     * 新增role_publishuser表
     * @param rolesPublishuser role_publishuser表
     * @return R
     */
    @ApiOperation(value = "新增role_publishuser表", notes = "新增role_publishuser表")
    @PostMapping
    public ResponseEntity<Object> save(@RequestBody RolesPublishuser rolesPublishuser) {
        return ResponseEntity.ok(rolesPublishuserService.save(rolesPublishuser));
    }

    /**
     * 修改role_publishuser表
     * @param rolesPublishuser role_publishuser表
     * @return R
     */
    @ApiOperation(value = "修改role_publishuser表", notes = "修改role_publishuser表")
    @PutMapping
    public ResponseEntity<Object> updateById(@RequestBody RolesPublishuser rolesPublishuser) {
        return ResponseEntity.ok(rolesPublishuserService.updateById(rolesPublishuser));
    }

    /**
     * 通过id删除role_publishuser表
     * @param roleId id
     * @return R
     */
    @ApiOperation(value = "通过id删除role_publishuser表", notes = "通过id删除role_publishuser表")
    @DeleteMapping("/{roleId}" )
    public ResponseEntity<Object> removeById(@PathVariable String roleId) {
        return ResponseEntity.ok(rolesPublishuserService.removeById(roleId));
    }

}
